<template>
  <PageContainer>
    <view class="container">
      <Header title="申请撮合记录" />
      <Paglist
        v-model="dataList"
        :is-init-api="false"
        :parame="params"
        @register="register"
        :is-show-loadmore="dataList.length > 1"
        :scroll-top-bottom="200"
        emptyText="您暂未提交过撮合申请"
      >
        <view class="pa-16">
          <template v-for="(v, i) in dataList" :key="v.id">
            <view class="bg-white mb-12 br-8">
              <view class="header disFlxJS pa-12">
                <text class="fz-14 font-bold default-color br-8 flex-1 ov-1">
                  {{ v.createTime }}
                </text>
              </view>
              <view class="pa-12">
                <MatchingItem :id="v.id" :status="v.flowStatus" />
              </view>
            </view>
          </template>
        </view>
      </Paglist>
    </view>
  </PageContainer>
</template>

<script lang="ts" setup>
  /* applicationMatchingRecord 申请撮合记录 */
  import Header from '@/components/Header/index.vue';
  import PageContainer from '@/components/PageContainer/index.vue';
  import { onLoad } from '@/router';
  import Paglist from '@/components/Paglist/index.vue';
  import { useConList } from '@/components/Paglist/useConList';
  import { provide, reactive, ref } from 'vue';
  import { onPageScroll } from '@dcloudio/uni-app';
  import MatchingItem from '../components/MatchingItem.vue';
  import { intentionApplyTypePage } from '@/api/businessOpportunities';
  import type {
    IIntentionApplyTypePage,
    IIntentionApplyTypePageResult,
  } from '@/api/businessOpportunities/type';

  const params = reactive<IIntentionApplyTypePage>({
    applyRecordId: Infinity,
  });
  const dataList = ref<IIntentionApplyTypePageResult[]>([]);
  const [register, { refresh }] = useConList();

  provide('api', intentionApplyTypePage);

  onLoad<'applicationMatchingRecord'>((op) => {
    params.applyRecordId = op.id;
    refresh();
  });

  onPageScroll(() => {});
</script>

<style lang="scss" scoped>
  .header {
    border-bottom: 1px solid #ebedf0;
  }
</style>
